#用for循环进行计数
def for_sum():
    sum=0
    a=[0,5,8,3,4,False,None]
    for i in a:
        if type(i) == int:
            sum += i
    return f"当前for循环sum值为:{sum}"

#while循环进行计数,while循环一定要有退出机制
def while_sum():
    sum=50
    while sum<=500:
        if sum>500:
            break
        sum+=100
    return f"当前while循环sum值为:{sum}"

#用for和while循环实现裴波那契函数f(n)=f(n-1)+f(n-2)           [0,1,1,2,3,5,8,13...]
def pbnq():
    n1=0
    n2=1
    n3=0
    arr=[0,1]
    while n3<100:
        n3=n1+n2
        if n3>=100:
            break
        n1=n2
        n2=n3
        arr.append(n3)
    return f"裴波那契函数(100以内)：{arr}"

#简约计算器
def calculator(a,b):
    res = 0
    a = int(a)
    b = int(b)
    if c == "+":
        res = a+b
    if c == "-":
        res = a-b
    if c == "*":
        res = a*b
    if c == "/":
        try:
            res = a/b
        except:
            return "运算出错，分母不能为0"
    if c == "%":
        try:
            res = a%b
        except:
            return "运算出错，分母不能为0"
    if c == "//":
        try:
            res = a//b
        except:
            return "运算出错，分母不能为0"
    if c == "**":
        res = a ** b
    return f"{a}{c}{b}运算结果是:{res}"

a=input("输入第一个：")
b=input("输入第二个：")
c=input("输入运算符：")
if a.isdigit() == True and b.isdigit() == True:
    pass
else:
    print("请输入数字进行计算！")

if __name__ == '__main__':
    res_for_sum=for_sum()
    print(res_for_sum)

    res_while_sum=while_sum()
    print(res_while_sum)

    res_pbnq=pbnq()
    print(res_pbnq)

    res_calculator = calculator(a,b)
    print(res_calculator)